<?php
require_once "config.php";
$id = $_GET['id'];
$u_id = $_GET['u_id'];
$goods_sql = $mysql->query("select * from dyspw_goods where id=".$id);//è§†é¢‘
$goods = $goods_sql->fetch_all(MYSQLI_ASSOC);
$info_img = explode(",",$goods[0]['info_img']);
$info_img = array_filter($info_img);
$info = explode(",",$goods[0]['info']);
$info = array_filter($info);
$goods_info = array();
foreach ($info_img as $key => $val) {
    $goods_info[$key]['img'] = $val;
    if(!empty($info[$key])){$goods_info[$key]['info'] = $info[$key];}

}
// echo $goods[0]['introduce'];exit;
$recommend_sql = $mysql->query("select * from dyspw_goods where u_id=".$goods[0]['u_id']." and id != {$id} ORDER BY time DESC limit 6");//è§†é¢‘
$recommend = $recommend_sql->fetch_all(MYSQLI_ASSOC);
 ?>
 <!DOCTYPE html>
 <html>
 <head>
 	<meta charset="utf-8">
 	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
 	<title><?php echo $goods[0]['title'] ?></title>
 	<script src="js/mui.min.js"></script>
 	<link href="css/mui.min.css" rel="stylesheet" />
 	<link href="css/productDetail.css" rel="stylesheet" />
 	<script type="text/javascript" charset="utf-8">
 		mui.init();
 	</script>
 <script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?cb5d49b07e0a753dc8ee27ba2c73495d";
  var s = document.getElementsByTagName("script")[0];
  s.parentNode.insertBefore(hm, s);
})();
</script>
</head>

 <body>
 	<div class="container">
 		<div class="topImg" style="position: relative;width:100%; background:url('<?php echo $goods[0]['img'] ?>') center center no-repeat; background-size: cover;" >
            <!-- <img src="<?php echo $goods[0]['img'] ?>" /> -->
            <a href="javascript:history.back(-1)" class="back" style="position: absolute;width: 40px;height: 40px;z-index: 999;top: 5px;left: 5px;display: inline-block;background: #a09e9e;border-radius: 50px;">
                <img src="images/back.png" style="width: 35px;height: 35px;left: 50%;top: 50%;position: relative;transform: translate(-50%,-50%);"/>
            </a>
        </div>
 		<div class="info">
 			<div class="money"><?php if(!empty($goods[0]['rob'])){echo "特价：￥";}else{echo '团购价：￥';} ?><?php echo $goods[0]['group_money'] ?><span style="color:#aaa; font-size14px;">原价：<?php echo $goods[0]['money'] ?></span></div>
 			<div class="title">总量：<?php echo $goods[0]['stock']?>&nbsp; 已售：<?php echo $goods[0]['sales']?></div>
 			<div class="title"><?php echo $goods[0]['title'] ?></div>
            <div class="infoDetail"><?php echo $goods[0]['details'] ?></div>
 		</div>


 		<div class="band">
 			<div class="bandInfo ">
 				<div class="logo">
 					<img src="<?php echo $goods[0]['u_avatar']; ?>" />
 				</div>
 				<div class="compName">
 					<div class="name"><?php echo $goods[0]['u_name'] ?></div>
 					<div class="zan">5.5万人点赞</div>
 				</div>
 			</div>
 			<div class="btns">
 				<!-- <button type="button" class="mui-btn connect">联系客服</button> -->
 				<button type="button" class="mui-btn "><a href="mem_goods.php?id=<?php echo $goods[0]['u_id']; ?>" style="color:#333;">进店逛逛</a></button>
 			</div>
 		</div>

       <?php if(!empty($goods_info) || !empty($goods[0]['introduce'])){ ?>
 		<div class="showpictures">
            <?php foreach ($goods_info as $key => $val) {?>
                <img src="<?php echo $val['img']; ?>" />
                <div class="button-info">
         			<span><?php if(!empty($val['info'])){echo $val['info'];} ?></span>
         		</div>
            <?php } ?>
            <div class="button-info">
                <div v-html="text2" style="width:100%;"> <pre style="white-space:pre-wrap; width:100%;text-indent:5px"><?php echo $goods[0]['introduce']; ?></pre></div>
                <script type="text/javascript">
                    $(".button-info").text2 = arr.join('<br>');

                </script>
            </div>
 		</div>
        <?php }?>

 		<div class="commodity " style="margin-bottom:30px;">
 			<div class="title">推荐</div>
 			<div class="list">
                <?php foreach ($recommend as $key => $val) {?>
                    <div class="item">
                        <a href="goods_info.php?id=<?php echo $val['id']; ?>">
     					<div class="itemImg">
     						<img style="object-fit: cover;" src="<?php echo $val['img'] ?>" />
     					</div>
     					<div class="itemInfo">
     						<div class="itemTitle">
     							<?php echo $val['title']; ?>
     						</div>
     						<div class="itemDesc">
     							<?php echo $val['details']; ?>
     						</div>
     						<div class="soldDetail">
     							<div class="itemPrice">
     								<span class="symbol"></span><span class="symbol" style="font-size: 12px;">团购价:¥<?php echo $val['group_money']; ?><em style="color: #999;font-size: 10px;margin-left: 5px;">原价:￥<?php echo $val['money']; ?></em></span>
     							</div>
     							<div class="soldNum">
     								已售五份
     							</div>
     						</div>
     					</div>
                    </a>
     				</div>
                <?php } ?>


 			</div>
 		</div>
 		<div class="footer" style="position: fixed;bottom: 0px;">
 			<div class="footer-img">
 				<!-- <img src="images/car.png" /> -->
 			</div>
 			<div class="btn-box">
 				<!-- <button>加入购物车</button> -->
 				<button ><a href="goods_order.php?id=<?php echo $id; ?>&u_id=<?php echo $u_id; ?>" style="color:#fff;">立即购买</a></button>
 			</div>
 		</div>
 	</div>
 </body>
 </html>
